<template>
  <div>
    <el-dialog title="收货地址" :visible.sync="dialogFormVisible">
      <el-form
        :model="form"
        status-icon
        :rules="rules"
        ref="ruleForm"
        label-width="100px"
        class="demo-ruleForm"
      >
        <el-form-item label="书店名称" prop="storeName">
          <el-input v-model="form.storeName"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="toStore()">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  components: {},
  props: {},
  data() {
    return {
      dialogFormVisible: false,
      form: {
        storeName: "",
      },
      rules: {
        storeName: [
          { required: true, message: "请输入活动名称", trigger: "blur" },
          { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" },
        ],
      },
    };
  },
  computed: {},
  methods: {
    changeDialogFormVisible(param) {
      this.dialogFormVisible = param;
    },
    toStore() {
      this.dialogFormVisible = false;
      let storeInfo = {
        userId: this.$store.state.user.user.userId,
        storeName: this.form.storeName,
      };
      this.$axios.post("sys/store/toStore", storeInfo).then(({ data }) => {
        if (data.code == 201) {
          this.$message.success("开通书店成功");
          this.$emit("refresh");
        }
      });
    },
  },
};
</script>

<style lang='less' scoped>
</style>